package cn.stronglink.oil.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by Tgb on 2018/1/24.
 */

public class SharedPreferencesUtil {
    /**
     * 保存ip
     * @param context
     * @param ip
     */
    public static void saveIp(Context context, String ip){
        SharedPreferences pref = context.getSharedPreferences("ip",context.MODE_PRIVATE);
        SharedPreferences.Editor editor = pref.edit();
        editor.putString("ip",ip);
        editor.commit();
    }

    public static String getIp(Context context){
        SharedPreferences pref = context.getSharedPreferences("ip",context.MODE_PRIVATE);
        // String ip = pref.getString("ip","127.0.0.1:8080/asset");//第二个参数为默认值
        String ip = pref.getString("ip","");//第二个参数为默认值
        return ip;
    }

    /**
     * 保存ip
     * @param context
     * @param ip
     */
    public static void saveCameraIp(Context context, String cameraIp){
        SharedPreferences pref = context.getSharedPreferences("cameraIp",context.MODE_PRIVATE);
        SharedPreferences.Editor editor = pref.edit();
        editor.putString("cameraIp",cameraIp);
        editor.commit();
    }

    public static String getCameraIp(Context context){
        SharedPreferences pref = context.getSharedPreferences("cameraIp",context.MODE_PRIVATE);
        // String ip = pref.getString("ip","127.0.0.1:8080/asset");//第二个参数为默认值
        String cameraIp = pref.getString("cameraIp","");//第二个参数为默认值
        return cameraIp;
    }
}
